2.3.áInstalling on Linux hosts

2.3.1.áPrerequisites

For the various versions of Linux that we support as host operating systems, please refer to Sectioná1.4, “Supported host operating systems”.

You will need to install the following packages on your Linux system before starting the installation (some systems will do this for you automatically when you install VirtualBox):

  • Qt 4.3.0 or higher;

  • SDL 1.2.7 or higher (this graphics library is typically called libsdl or similar).

Note

To be precise, these packages are only required if you want to run the VirtualBox graphical user interfaces. In particular, VirtualBox, our main graphical user interface, requires both Qt and SDL; VBoxSDL, our simplified GUI, requires only SDL. By contrast, if you only want to run the headless VRDP server that comes with VirtualBox, neither Qt nor SDL are required.

2.3.2.áThe VirtualBox kernel module

Most people who install VirtualBox using packages specially created for their Linux distribution will be able to safely skip this section unless they run into problems during the installation. All that they will need to remember is that they may have to reinstall VirtualBox (or recreate the VirtualBox kernel module by running

/etc/init.d/vboxdrv setup

as root) if the Linux kernel on their system is updated.

VirtualBox uses a special kernel module to perform physical memory allocation and to gain control of the processor for guest system execution. Without this kernel module, you will still be able to work with virtual machines in the configuration interface, but you will not be able to start any virtual machines.

To be able to install this kernel module, you will have to prepare your system for building external kernel modules. As this process can vary from system to system, we will only describe what to do for systems we have tested

  • Most Linux distributions can be set up simply by installing the right packages. Normally, these will be the GNU compiler (GCC), GNU Make (make) and packages containing header files for your kernel. The version numbers of the header file packages must be the same as that of the kernel you are using.

    • For recent Linux distributions (for example Fedora Core 5 and later, Ubuntu 7.10 (Gutsy) and later and Mandriva 2007.1 and later) we recommend installing DKMS. This framework helps to build kernel modules and to deal with kernel upgrades.

    • In newer Debian and Ubuntu releases, you must install the right version of the linux-headers and if it exists the linux-kbuild package. Current Ubuntu releases should have the right packages installed by default.

    • In older Debian and Ubuntu releases, you must install the right version of the kernel-headers package.

    • On Fedora and Redhat systems, the package is kernel-devel.

    • On SUSE and OpenSUSE Linux, you must install the right versions of the kernel-source and kernel-syms packages.

  • Alternatively, if you built your own kernel /usr/src/linux will point to your kernel sources, and you have not removed the files created during the build process, then your system will already be correctly set up.

2.3.3.áUSB and advanced networking support

In order to use VirtualBox's USB support, the user account under which you intend to run VirtualBox must have read and write access to the USB filesystem (usbfs).

In addition, access to /dev/net/tun will be required if you want to use Host Interface Networking, which is described in detail in Sectioná6.5, “Introduction to Host Interface Networking (HIF)”.

2.3.4.áPerforming the installation

VirtualBox is available in a number of package formats native to various common Linux distributions (see Sectioná1.4, “Supported host operating systems” for details). In addition, there is an alternative generic installer (.run) which should work on most Linux distributions.

2.3.4.1.áInstalling VirtualBox from a Debian/Ubuntu package

First, download the appropriate package for your distribution. The following examples assume that you are installing to an Ubuntu Edgy system. Use dpkg to install the Debian package:

sudo dpkg -i VirtualBox_2.0.6_Ubuntu_edgy.deb

You will be asked to accept the VirtualBox Personal Use and Evaluation License. Unless you answer "yes" here, the installation will be aborted.

The group vboxusers will be created during installation. Note that a user who is going to run VirtualBox must be member of that group. A user can be made member of the group vboxusers through the GUI user/group management or at the command line with

sudo usermod -a -G vboxusers username

Also note that adding an active user to that group will require that user to log out and back in again. This should be done manually after successful installation of the package.

The installer will also search for a VirtualBox kernel module suitable for your kernel. The package includes pre-compiled modules for the most common kernel configurations. If no suitable kernel module is found, the installation script tries to build a module itself. If the build process is not successful you will be shown a warning and the package will be left unconfigured. Please have a look at /var/log/vbox-install.log to find out why the compilation failed. You may have to install the appropriate Linux kernel headers (see Sectioná2.3.2, “The VirtualBox kernel module”). After correcting any problems, do

sudo /etc/init.d/vboxdrv setup

This will start a second attempt to build the module.

If a suitable kernel module was found in the package or the module was successfully built, the installation script will attempt to load that module. If this fails, please see Sectioná11.5.1, “Linux kernel module refuses to load” for further information.

Once VirtualBox has been successfully installed and configured, you can start it by selecting "VirtualBox" in your start menu or from the command line (see Sectioná2.3.5, “Starting VirtualBox on Linux”).

2.3.4.2.áUsing the alternative installer (VirtualBox.run)

The alternative installer performs the following steps:

  • It unpacks the application files to a target directory of choice. By default, the following directory will be used:

    /opt/VirtualBox-2.0.6
  • It builds the VirtualBox kernel module (vboxdrv) and installs it.

  • It creates /etc/init.d/vboxdrv, an init script to start the VirtualBox kernel module.

  • It creates a new system group called vboxusers.

  • It creates symbolic links to VirtualBox, VBoxSDL, VBoxVRDP, VBoxHeadless and VBoxManage in /usr/bin.

  • It creates /etc/udev/60-vboxdrv.rules, a description file for udev, if that is present, which makes the module accessible to anyone in the group vboxusers.

  • It writes the installation directory to /etc/vbox/vbox.cfg.

The installer must be executed as root with either install or uninstall as the first parameter. If you do not want the installer to ask you whether you wish to accept the license agreement (for example, for performing unattended installations), you can add the parameter license_accepted_unconditionally. Finally, if you want to use a directory other than the default installation directory, add the desired path as an extra parameter.

sudo ./VirtualBox.run install /opt/VirtualBox

Or if you do not have the "sudo" command available, run the following as root instead:

./VirtualBox.run install /opt/VirtualBox

After that you need to put every user which should be able to use VirtualBox in the group vboxusers, either through the GUI user management tools or by running the following command as root:

sudo usermod -a -G vboxusers username

Note

The usermod command of some older Linux distributions does not support the -a option (which adds the user to the given group without affecting membership of other groups). In this case, find out the current group memberships with the groups command and add all these groups in a comma-separated list to the command line after the -G option, e.g. like this: usermod -G group1,group2,vboxusers username.

If any users on your system should be able to access host USB devices from within VirtualBox guests, you should also add them to the appropriate user group that your distribution uses for USB access, e.g. usb or usbusers.

2.3.4.3.áPerforming a manual installation

If, for any reason, you cannot use the shell script installer described previously, you can also perform a manual installation. Invoke the installer like this:

./VirtualBox.run --keep --noexec

This will unpack all the files needed for installation in the directory install under the current directory. The VirtualBox application files are contained in VirtualBox.tar.bz2 which you can unpack to any directory on your system. For example:

sudo mkdir /opt/VirtualBox
sudo tar jxf ./install/VirtualBox.tar.bz2 -C /opt/VirtualBox

or as root:

mkdir /opt/VirtualBox
tar jxf ./install/VirtualBox.tar.bz2 -C /opt/VirtualBox

The sources for VirtualBox's kernel module are provided in the src directory. To build the module, change to the directory and issue

make

If everything builds correctly, issue the following command to install the module to the appropriate module directory:

sudo make install

In case you do not have sudo, switch the user account to root and perform

make install

The VirtualBox kernel module needs a device node to operate. The above make command will tell you how to create the device node, depending on your Linux system. The procedure is slightly different for a classical Linux setup with a /dev directory, a system with the now deprecated devfs and a modern Linux system with udev.

On certain Linux distributions, you might experience difficulties building the module. You will have to analyze the error messages from the build system to diagnose the cause of the problems. In general, make sure that the correct Linux kernel sources are used for the build process.

Note that the user who is going to run VirtualBox needs read and write permission on the VirtualBox kernel module device node /dev/vboxdrv. You can either define a vboxusers group by entering

groupadd vboxusers
chgrp vboxusers /dev/vboxdrv
chmod 660 /dev/vboxdrv

or, alternatively, simply give all users access (insecure, not recommended!)

chmod 666 /dev/vboxdrv

You should also add any users who will be allowed to use host USB devices in VirtualBox guests to the appropriate USB users group for your distribution. This group is often called usb or usbusers.

Next, you will have to install the system initialization script for the kernel module:

cp /opt/VirtualBox/vboxdrv.sh /etc/init.d/vboxdrv

(assuming you installed VirtualBox to the /opt/VirtualBox directory) and activate the initialization script using the right method for your distribution. You should create VirtualBox's configuration file:

mkdir /etc/vbox
echo INSTALL_DIR=/opt/VirtualBox > /etc/vbox/vbox.cfg

and, for convenience, create the following symbolic links:

ln -sf /opt/VirtualBox/VBox.sh /usr/bin/VirtualBox
ln -sf /opt/VirtualBox/VBox.sh /usr/bin/VBoxSVC
ln -sf /opt/VirtualBox/VBox.sh /usr/bin/VBoxManage

2.3.4.4.áUpdating and uninstalling VirtualBox

Before updating or uninstalling VirtualBox, you must terminate any virtual machines which are currently running and exit the VirtualBox or VBoxSVC applications. To update VirtualBox, simply run the installer of the updated version. To uninstall VirtualBox, invoke the installer like this:

sudo ./VirtualBox.run uninstall

or as root

./VirtualBox.run uninstall

To manually uninstall VirtualBox, simply undo the steps in the manual installation in reverse order.

2.3.4.5.áAutomatic installation of Debian packages

The Debian packages will request some user feedback when installed for the first time. The debconf system is used to perform this task. To prevent any user interaction during installation, default values can be defined. A file vboxconf can contain the following debconf settings:

virtualbox virtualbox/module-compilation-allowed boolean true
virtualbox virtualbox/delete-old-modules boolean true

The first line allows compilation of the vboxdrv kernel module if no module was found for the current kernel. The second line allows the package to delete any old vboxdrv kernel modules compiled by previous installations.

These default settings can be applied with

debconf-set-selections vboxconf

prior to the installation of the VirtualBox Debian package.

2.3.4.6.áAutomatic installation of .rpm packages

The .rpm format does not provide a configuration system comparable to the debconf system. To configure the installation process of our .rpm packages, a file /etc/default/virtualbox is interpreted. The automatic generation of the udev rule can be prevented by the following setting:

INSTALL_NO_UDEV=1

The creation of the group vboxusers can be prevented by

INSTALL_NO_GROUP=1

If the line

INSTALL_NO_VBOXDRV=1

is specified, the package installer will not try to build the vboxdrv kernel module if no module according to the current kernel was found.

2.3.5.áStarting VirtualBox on Linux

The easiest way to start a VirtualBox program is by running the program of your choice (VirtualBox, VBoxManage, VBoxSDL or VBoxHeadless) from a terminal. These are symbolic links to VBox.sh that start the required program for you.

The following detailed instructions should only be of interest if you wish to execute VirtualBox without installing it first. You should start by compiling the vboxdrv kernel module (see above) and inserting it into the Linux kernel. VirtualBox consists of a service daemon (VBoxSVC) and several application programs. The daemon is automatically started if necessary. All VirtualBox applications will communicate with the daemon through Unix local domain sockets. There can be multiple daemon instances under different user accounts and applications can only communicate with the daemon running under the user account as the application. The local domain socket resides in a subdirectory of your system's directory for temporary files called .vbox-<username>-ipc. In case of communication problems or server startup problems, you may try to remove this directory.

All VirtualBox applications (VirtualBox, VBoxSDL, VBoxManage and VBoxHeadless) require the VirtualBox directory to be in the library path:

LD_LIBRARY_PATH=. ./VBoxManage showvminfo "Windows XP"